<HTML>
  <head>
    <script type="text/javascript" src="http://oauth.googlecode.com/svn/code/javascript/sha1.js"></script>
    <script type="text/javascript" src="http://oauth.googlecode.com/svn/code/javascript/oauth.js"></script>
    <script type="text/javascript">
function sign(form) {
    var accessor = { consumerSecret: form.consumerSecret.value
                   , tokenSecret   : form.tokenSecret.value};
    var message = { method: form.httpMethod.value
                  , action: form.URL.value
                  , parameters: OAuth.decodeForm(form.parameters.value)
                  };
    for (var e = 0; e < form.elements.length; ++e) {
        var input = form.elements[e];
        if (input.name != null && input.name.substring(0, 6) == "oauth_"
            && input.value != null && input.value != ""
            && (!(input.type == "checkbox" || input.type == "radio") || input.checked))
        {
            message.parameters.push([input.name, input.value]);
        }
    }
    OAuth.SignatureMethod.sign(message, accessor);
    showText("normalizedParameters", OAuth.SignatureMethod.normalizeParameters(message.parameters));
    showText("signatureBaseString" , OAuth.SignatureMethod.getBaseString(message));
    showText("signature"           , OAuth.getParameter(message.parameters, "oauth_signature"));
    showText("authorizationHeader" , OAuth.getAuthorizationHeader("", message.parameters));
    return false;
}
function showText(elementId, text) {
    var child = document.createTextNode(text);
    var element = document.getElementById(elementId);
    if (element.hasChildNodes()) {
        element.replaceChild(child, element.firstChild);
    } else {
        element.appendChild(child);
    }
}
function freshTimestamp() {
    document.request.oauth_timestamp.value = OAuth.timestamp();
}
function freshNonce() {
    document.request.oauth_nonce.value = OAuth.nonce(11);
}
    </script>
  </head>
  <body onLoad="freshNonce();freshTimestamp()">
To compute an
<a href="http://oauth.net">OAuth</a>
<a href="http://oauth.net/core/1.0/#signing_process">request signature</a>,
fill in this form and click the 'Sign' button.
    <form name="request">
      <table border="0">
        <tr><th align="right">HTTP method:      </th><td><input name="httpMethod"             type="text" size="5"  value="GET"/></td></tr>
        <tr><th align="right">URL:              </th><td><input name="URL"                    type="text" size="80" value="http://host.net/resource"></td></tr>
        <tr><th align="right">parameters:       </th><td><input name="parameters"             type="text" size="80" value="name=value&amp;name=value"/></td></tr>
        <tr><th align="right">version:          </th><td><input name="oauth_version"          type="text" size="4"  value="1.0"/></td></tr>
        <tr><th align="right">consumer key:     </th><td><input name="oauth_consumer_key"     type="text" size="64" value="abcd"/></td></tr>
        <tr><th align="right">consumer secret:  </th><td><input name="consumerSecret"         type="text" size="64" value="efgh"/></td></tr>
        <tr><th align="right">token:            </th><td><input name="oauth_token"            type="text" size="64" value="ijkl"/></td></tr>
        <tr><th align="right">token secret:     </th><td><input name="tokenSecret"            type="text" size="64" value="mnop"/></td></tr>
        <tr><th align="right">timestamp:        </th><td><input name="oauth_timestamp"        type="text" size="12"/>
                                                         <input type="button" value="now" onClick="freshTimestamp()"/></td></tr>
        <tr><th align="right">nonce:            </th><td><input name="oauth_nonce"            type="text" size="12"/>
                                                         <input type="button" value="random" onClick="freshNonce()"/></td></tr>
        <tr><th align="right">signature method: </th><td><input name="oauth_signature_method" type="text" size="12" value="HMAC-SHA1"/></td></tr>
      </table>
      <input type="button" value="Sign" onClick="sign(document.request)"/>
      <input type="reset"  value="Reset"/>
      <br/>
      <table border="2">
        <tr valign="baseline"><th align="right">normalized parameters:</th><td><pre id="normalizedParameters">&nbsp;</pre></td></tr>
        <tr valign="baseline"><th align="right">signature base string:</th><td><pre id="signatureBaseString"> &nbsp;</pre></td></tr>
        <tr valign="baseline"><th align="right">signature:            </th><td><pre id="signature">           &nbsp;</pre></td></tr>
        <tr valign="baseline"><th align="right">Authorization header: </th><td><pre id="authorizationHeader"> &nbsp;</pre></td></tr>
      </table>
    </form>
  </body>
</HTML>
